import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

export const constantRouterMap = [{
		path: '/login',
		component: () =>
			import('@/views/login/index'),
		hidden: true
	},
	{
		path: '/404',
		component: () =>
			import('@/views/404'),
		hidden: true
	},
	//主页
	{
		path: '/',
		component: Layout,
		redirect: 'dashboard',
		name: 'Dashboard',
		hidden: true,
		children: [{
			path: 'dashboard',
			component: () =>
				import('@/views/dashboard/index')
		}]
	},

	//会员
	{
		path: '/member',
		component: Layout,
		redirect: '/member/member',
		name: 'Member',
		meta: {
			title: '管理',
			icon: 'user'
		},
		children: [{
				path: 'member',
				name: 'member',
				component: () =>
					import('@/views/member/member'),
				meta: {
					title: '会员',
					icon: 'table'
				}
			},
			{
				path: 'agent',
				name: 'agent',
				component: () =>
					import('@/views/member/agent'),
				meta: {
					title: '代理商',
					icon: 'tree'
				}
			}
		]
	},

	//商城
	{
		path: '/mall',
		component: Layout,
		redirect: '/mall/shopList',
		alwaysShow: true,
		name: 'mall',
		meta: {
			title: '商城',
			icon: 'store-front'
		},
		children: [{
				path: 'addShop',
				name: 'aShop',
				component: () =>
					import('@/views/mall/add-shop'),
				meta: {
					title: '添加商品',
					icon: 'example'
				}
			},
			{
				path: 'shopList',
				name: 'sList',
				component: () =>
					import('@/views/mall/shopList'),
				meta: {
					title: '商品列表',
					icon: 'example'
				}
			},
			{
				path: 'orderList',
				name: 'oList',
				component: () =>
					import('@/views/mall/orderList'),
				meta: {
					title: '订单列表',
					icon: 'example'
				}
			},
			{
				path: 'shopRefund',
				name: 'sRefund',
				component: () =>
					import('@/views/mall/refund_list'),
				meta: {
					title: '退货退款',
					icon: 'example'
				}
			},
			{
				path: 'order-detail/:row',
				name: 'order-detail',
				hidden: true,
				component: () =>
					import('@/views/mall/other/order-detail'),
				meta: {
					title: '订单详情',
					icon: 'example',
					noCache: true
				}
			},
			{
				path: 'shopDetail/:id',
				name: 'sDetail',
				hidden: true,
				component: () =>
					import('@/views/mall/other/shop_detail.vue'),
				meta: {
					title: '商品详情',
					icon: 'example',
					noCache: true
				}
			},
		]
	},

	//	 //商品详情
	//	{
	//		path: '/shopDetail/:row',
	//		component: Layout,
	//		redirect: '/dashboard',
	//		name: 'Dashboard',
	//		hidden: true,
	//		children: [{
	//			path: 'dashboard',
	//			component: () =>
	//				import('@/views/dashboard/index')
	//		}]
	//	},

	//知识
	{
		path: '/know', //第一层路由名称
		component: Layout, //框架
		redirect: '/know/know-ku', //点击第一层标题会进入的页面
		name: 'know',
		meta: {
			title: '知识',
			icon: 'example'
		}, //路径
		children: [{
				path: 'know-ku', //url地址名称
				name: 'ku', //别名 必须是英文
				component: () =>
					import('@/views/know/know-ku'), //路由地址
				meta: {
					title: '知识库',
					icon: 'example'
				}
			},
			{
				path: 'know-list',
				name: 'list',
				component: () =>
					import('@/views/know/know-list'),
				meta: {
					title: '知识列表',
					icon: 'tree'
				}
			}
		]
	},

	//	{
	//		path: '/form',
	//		component: Layout,
	//		children: [{
	//			path: 'index',
	//			name: 'Form',
	//			component: () =>
	//				import('@/views/form/index'),
	//			meta: {
	//				title: 'Form',
	//				icon: 'form'
	//			}
	//		}]
	//	},

	//	{
	//		path: '*',
	//		redirect: '/404',
	//		hidden: true
	//	}
]

export default new Router({
	// mode: 'history', //后端支持可开
	scrollBehavior: () => ({
		y: 1
	}),
	routes: constantRouterMap
})

//export const asyncRouterMap = [
//
//
//
//]